package com.lagou.edu.controller;


import com.lagou.edu.pojo.User;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

/**
 * @author: liujunling
 * @createDate: 2020/4/20
 */

@Controller
@RequestMapping("login")
public class LoginController {


  @RequestMapping("user")
  public String login(User user,HttpSession session){
    String username = user.getUsername();
    String password = user.getPassword();
    if(StringUtils.isBlank(username) || StringUtils.isBlank(password)){
      session.setAttribute("loginError","请输入账号密码");
      return "forward:/";
    }
    if(username.equals("admin") && password.equals("admin")){
      session.setAttribute("isLogin",true);
      return "redirect:/resume/list";
    }else {
      session.setAttribute("loginError","账号密码错误");
      return "forward:/";
    }

  }



}


